<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layui/css/global.css" media="all">
    <link rel="stylesheet" href="/static/layer-v3.1.1/layer/theme/default/layer.css" media="all">
    <link rel="stylesheet" href="/static/jujiu/var.css" media="all">
    <title>Jujiu</title>
    <link rel="icon" href="/static/favicon.ico" type="image/x-icon">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script>
        // var domain = "localhost"
        var domain = "jenkins.silcs.net"
        var h2fUrl = "http://" + domain + ":9090/api/v1/data/syn/Hangzhou2Frankfurt?deviceId="
        var r2dUrl = "http://" + domain + ":9090/api/v1/data/syn/real2dev?deviceId="

        var mv2FrkUrl = "http://" + domain + ":9090/api/v1/dispatch/cn2eu?deviceId="
        var mv2DevUrl = "http://" + domain + ":9090/api/v1/dispatch/cn2dev?deviceId="
        var mvF2HUrl = "http://" + domain + ":9090/api/v1/dispatch/eu2cn?deviceId="
        var mvDev2RealUrl = "http://" + domain + ":9090/api/v1/dispatch/dev2cn?deviceId="
        var delRomUrl = "http://" + domain + ":9090/api/v1/romversion/delete?romVer="
        var dQueryUrl = "http://" + domain + ":9090/api/v1/query/device?deviceId="
        var commDisUrl = "http://" + domain + ":9090/api/v1/dispatch/common"
        var xhr;

        function dispatch() {
            // 获取设备号
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                layer.msg("设备号不可为空")
                return
            }
            // 获取当前集群
            let srcCid = document.getElementById("srcCid");
            let scid = srcCid.value;
            if (scid.trim() == "") {
                layer.msg("当前集群不可为空")
                return
            }
            // 获取目标集群
            let tarCid = document.getElementById("tarCid");
            let tcid = tarCid.value;
            if (tcid.trim() == "") {
                layer.msg("目标集群不可为空")
                return
            }
            layer.msg("迁移中，请稍后。。。")
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("POST", commDisUrl, true)
            xhr.setRequestHeader("Content-Type", "application/json");
            data = JSON.stringify({"deviceId": deviceId, "sCid": scid, "tCid": tcid});
            xhr.send(data);
        }

        function mv2Frk() {
            // var textContext = document.getElementById("device_info_temp");
            // console.log($("#device_info_temp").html())
            // layer.open({
            //     title: '设备信息',
            //     content: $("#device_info_temp").html()
            // })
            // return
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                layer.msg("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", mv2FrkUrl + deviceId, true)
            xhr.send();
        }

        function mv2Dev() {
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                layer.msg("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", mv2DevUrl + deviceId, true)
            xhr.send();
        }

        function mvF2H() {
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                layer.msg("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", mvF2HUrl + deviceId, true)
            xhr.send();
        }

        function mvDev2Real() {
            var imputEle = document.getElementById("deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                layer.msg("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", mvDev2RealUrl + deviceId, true)
            xhr.send();
        }

        function h2f() {
            var imputEle = document.getElementById("data_deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                layer.msg("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", h2fUrl + deviceId, true)
            xhr.send();
        }

        function r2d() {
            var imputEle = document.getElementById("data_deviceId");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                layer.msg("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change;
            xhr.open("GET", r2dUrl + deviceId, true)
            xhr.send();
        }

        //设备基本信息查询
        function dquery() {
            var imputEle = document.getElementById("query_device_id");
            let deviceId = imputEle.value;
            if (deviceId == "") {
                layer.msg("设备号不可为空")
                return
            }
            xhr = new XMLHttpRequest();
            xhr.onreadystatechange = state_Change_JSON_Handle;
            xhr.open("GET", dQueryUrl + deviceId, true)
            xhr.send();
            $("#query_device_button").addClass("layui-anim-rotate layui-anim-loop")
        }

        /**
         * 删除固件版本号
         */
        function delRom() {
            var imputEle = document.getElementById("romVer");
            let romVer = imputEle.value;
            if (romVer == "") {
                layer.msg("固件版本号为空")
                return
            }
            var msg = "确定要删除固件[" + romVer + "]吗？"
            if (confirm(msg) == true) {
                console.log("做删除操作")
                xhr = new XMLHttpRequest();
                xhr.onreadystatechange = state_Change;
                xhr.open("GET", delRomUrl + romVer, true)
                xhr.send();
            } else {
                console.log("删除终止")
            }
        }

        function state_Change_JSON_Handle() {
            if (xhr.readyState == 4) {// 4 = "loaded"
                if (xhr.status == 200) {// 200 = OK
                    if (isJson(xhr.responseText)) {
                        let parse = JSON.parse(xhr.responseText);
                        console.log(parse);
                        view(xhr.responseText)
                        layer.open({
                            title: '设备信息',
                            content: $("#device_info_temp").html()
                        })
                    } else {
                        layer.msg(xhr.responseText)
                    }
                } else {
                    layer.msg("error")
                }
                $("#query_device_button").removeClass("layui-anim-rotate layui-anim-loop")
            }
        }

        function view(data) {
            let parse = JSON.parse(data);
            document.getElementById("info_serial_id").innerHTML = parse.SerildId
            document.getElementById("info_device_id").innerHTML = parse.DeviceId
            document.getElementById("info_device_no").innerHTML = parse.DeviceNo
            document.getElementById("info_imei").innerHTML = parse.Imei
            document.getElementById("info_iccid").innerHTML = parse.Iccid
            document.getElementById("info_rom_ver").innerHTML = parse.MainRomVer
            document.getElementById("info_sub_rom_ver").innerHTML = parse.SubRomVer
            document.getElementById("info_module_ver").innerHTML = parse.ModuleVer
            document.getElementById("info_sn").innerHTML = parse.Sn
            document.getElementById("info_cid").innerHTML = parse.CCid
            document.getElementById("info_online").innerHTML = parse.Online

            document.getElementById("info_slot_disable").innerHTML = parse.SlotDisable
        }

        function state_Change() {
            if (xhr.readyState == 4) {// 4 = "loaded"
                if (xhr.status == 200) {// 200 = OK
                    layer.msg(xhr.responseText)
                } else {
                    layer.msg("error")
                }
            }
        }

        function isJson(str) {
            if (typeof str == 'string') {
                try {
                    JSON.parse(str);
                    return true;
                } catch (e) {
                    return false;
                }
            }
        }

    </script>
</head>
<body>
<div class="layui-row">
    <div class="layui-col-xs3">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend style="font-weight: 400;">快捷导航</legend>
        </fieldset>
        <div style="padding: 20px; background-color: #F2F2F2;">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            <a href="https://www.yuque.com/meokb8/sg9sab/lpnz6z" target="_blank">IOT接口文档</a>
                        </div>
                        <div class="layui-card-header">
                            <a href="http://10.18.0.78:8080/swagger-ui.html" target="_blank">Bagua-Swagger-cn</a>
                        </div>
                        <div class="layui-card-header">
                            <a href="http://10.28.8.243:8080/swagger-ui.html" target="_blank">Bagua-Swagger-cn-dev</a>
                        </div>
                        <div class="layui-card-header">
                            <a href="http://172.18.2.134:8080/swagger-ui.html" target="_blank">Bagua-Swagger-eu</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-xs6">
        <div class="layui-carousel" id="test1">
            <div carousel-item>
                <div>
                    <img src="https://cn-tools-file.oss-cn-shanghai.aliyuncs.com/pic/11.jpg"
                         style="width: 100%;height: 100%">
                </div>
                <div><img src="https://cn-tools-file.oss-cn-shanghai.aliyuncs.com/pic/222.jpg"
                          style="width: 100%;height: 100%"></div>
                <div><img src="https://cn-tools-file.oss-cn-shanghai.aliyuncs.com/pic/333.jpg"
                          style="width: 100%;height: 100%"></div>
                <div><img src="https://cn-tools-file.oss-cn-shanghai.aliyuncs.com/pic/444.jpg"
                          style="width: 100%;height: 100%"></div>
                <div><img src="https://cn-tools-file.oss-cn-shanghai.aliyuncs.com/pic/555.jpg"
                          style="width: 100%;height: 100%"></div>
            </div>
        </div>
    </div>
    <div class="layui-col-xs3">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend style="font-weight: 400;">待续？</legend>
        </fieldset>
    </div>
</div>


<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend style="font-weight: 400;">功能列表</legend>
</fieldset>

<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">设备调度</div>

                <div class="layui-card-body">
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input id="deviceId" type="tel" name="phone" lay-verify="required|phone"
                                   placeholder="请输入设备号"
                                   autocomplete="off" class="layui-input" style="height: 30px">

                        </div>
                        <div class="layui-input-inline" style="padding-left: 15px;">
                            <select id="srcCid" name="modules" lay-verify="required" lay-search=""
                                    style="height: 30px;">
                                <option value="">当前集群</option>
                                <option value="cn_dev">国内测试</option>
                                <option value="cn_real">国内线上</option>
                                <option value="eu_dev">海外测试</option>
                                <option value="eu_real">海外线上</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="padding-left: 15px;">
                            <select id="tarCid" name="modules" lay-verify="required" lay-search=""
                                    style="height: 30px;">
                                <option value="">目标集群</option>
                                <option value="cn_dev">国内测试</option>
                                <option value="cn_real">国内线上</option>
                                <option value="eu_dev">海外测试</option>
                                <option value="eu_real">海外线上</option>
                            </select>
                        </div>
                        <button onclick="dispatch()" type="button" class="layui-btn layui-btn-warm"
                                style="height: 30px; line-height: 30px;">调度
                        </button>
                        <span class="query_remark">(支持deviceId、deviceNo、IMEI调度)</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">固件删除</div>
                <div class="layui-card-body">
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input id="romVer" type="tel" name="phone" lay-verify="required|phone"
                                   placeholder="请输入固件版本号"
                                   autocomplete="off" class="layui-input" style="height: 30px">
                        </div>
                        <button onclick="delRom()" type="button" class="layui-btn layui-btn-sm layui-btn-normal"><i
                                    class="layui-icon"></i> 删除
                        </button>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">基本信息查询</div>
                <div class="layui-card-body">
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input id="query_device_id" type="tel" name="phone" lay-verify="required|phone"
                                   placeholder="请输入设备号"
                                   autocomplete="off" class="layui-input" style="height: 30px">
                        </div>
                        <button id="query_device_button" onclick="dquery()" type="button" class="layui-btn layui-btn-danger "
                                style="height: 30px; line-height: 30px">查询
                        </button>
                        <span class="query_remark">(支持deviceId、deviceNo、IMEI、SN、Iccid查询)</span>
                    </div>
                </div>
            </div>
        </div>
        <!--
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">数据同步</div>
                <div class="layui-card-body">
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input id="data_deviceId" type="tel" name="phone" lay-verify="required|phone"
                                   placeholder="请输入设备号"
                                   autocomplete="off" class="layui-input" style="height: 30px">
                        </div>
                        <button onclick="h2f()" type="button" class="layui-btn layui-btn-checked"
                                style="height: 30px; line-height: 30px">国内2海外
                        </button>
                        <button onclick="r2d()" type="button" class="layui-btn layui-btn-checked"
                                style="height: 30px; line-height: 30px">国内2测试
                        </button>
                    </div>
                </div>
            </div>
        </div>
        -->
    </div>
</div>
<!--
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend style="font-weight: 400;">其他功能</legend>
</fieldset>
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">XXXX</div>
                <div class="layui-card-body">
                    1<br>
                </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">22222</div>
                <div class="layui-card-body">
                    2<br>
                </div>
            </div>
        </div>
    </div>
</div>
-->
<!--
<div class="layui-row">
    <div class="layui-col-xs6">
        <div class="grid-demo grid-demo-bg1">

        </div>
    </div>
    <div class="layui-col-xs6">
        <div class="grid-demo grid-demo-bg1">
        </div>
    </div>
</div>
</div>
<div class="layui-row">
    <div class="layui-col-xs3">
        <div class="grid-demo grid-demo-bg1">3/12</div>
    </div>
    <div class="layui-col-xs3">
        <div class="grid-demo">3/12</div>
    </div>
    <div class="layui-col-xs3">
        <div class="grid-demo grid-demo-bg1">3/12</div>
    </div>
    <div class="layui-col-xs3">
        <div class="grid-demo">3/12</div>
    </div>
</div>
-->
<div hidden id="device_info_temp">
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            设备号:
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_device_no">YU67</div>
    </div>
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            序列号:
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_serial_id">YU67</div>
    </div>
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            当前集群:
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_cid">Hangzhou</div>
    </div>
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            是否在线:
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_online">Hangzhou</div>
    </div>
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            IMEI:
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_imei">867567040005803</div>
    </div>
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            设备ID:
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_device_id">962007099904257</div>
    </div>
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            SN:
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_sn">L615LJRU57</div>
    </div>

    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            模组版本号:
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_module_ver">00.05.01.12</div>
    </div>
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            固件版本号(主):
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_rom_ver">00.000.016</div>
    </div>
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            固件版本号(从):
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_sub_rom_ver">00.000.016</div>
    </div>
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            ICCID:
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_iccid">89860425111870957992</div>
    </div>
    <div style="padding-bottom: 4px;display: flex;">
        <div style="position: relative;max-width: 100%;min-height: 1px;display: block;flex: 0 0 40%;max-width: 50%;">
            禁用槽位:
        </div>
        <div style="position: relative;max-width: 100%;min-height: 1px;" id="info_slot_disable"></div>
    </div>
</div>
<script src="/static/layui/layui.js"></script>
<script src="/static/jquery/jquery.js"></script>
<script src="/static/layer-v3.1.1/layer/layer.js"></script>
<script>
    layui.use('carousel', function () {
        var carousel = layui.carousel;
        //建造实例
        carousel.render({
            elem: '#test1'
            , width: '100%' //设置容器宽度
            , arrow: 'always' //始终显示箭头
            //,anim: 'updown' //切换动画方式
        });
    });
</script>
</body>
</html>